<%@ page language="java" contentType="text/html; charset=utf-8" import="com.opensymphony.xwork2.ActionContext;"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>综合客户关系管理系统</title>
    <link href="<c:url value="/css/default.css"/>" rel="stylesheet" type="text/css" />
    
    <link href="<c:url value="/css/themes/style.css"/>" rel="stylesheet" type="text/css" />
    <link href="<c:url value="/css/themes/core.css"/>" rel="stylesheet" type="text/css" />
    
	<!--[if IE]>
	<link href="themes/css/ieHack.css" rel="stylesheet" type="text/css" media="screen"/>
	<![endif]-->
	<!--[if lte IE 9]>
	<script src="js/speedup.js" type="text/javascript"></script>
	<![endif]-->

 	<script>
 
    var _menus = <%=request.getAttribute("strSecMenu")%>
	 function chkpwd(obj){
		  var t=obj.value;
		  var id=getResult(t);
		  
		//定义对应的消息提示
		  var msg=new Array(4);
		  msg[0]="密码过短。";
		  msg[1]="密码安全性差。";
		  msg[2]="密码强度良好。";
		  msg[3]="密码强度很高。";
		  
		  var sty=new Array(4);
		  sty[0]=-45;
		  sty[1]=-30;
		  sty[2]=-15;
		  sty[3]=0;
		  
		  var col=new Array(4);
		  col[0]="gray";
		  col[1]="red";
		  col[2]="#ff6600";
		  col[3]="Green";
		  
		  var sWidth=200;
		  var sHeight=15;
		  var Bobj=document.getElementById("chkResult"); 
		
		  Bobj.style.fontSize="12px";
		  Bobj.style.color=col[id];
		  Bobj.style.width=sWidth + "px";
		  Bobj.style.height=sHeight + "px";
		  Bobj.style.lineHeight=sHeight + "px";
		  Bobj.style.textIndent="20px";
		  Bobj.innerHTML="检测提示：" + msg[id];
	 }
	 
	 function getResult(s){
		  if(s.length < 6){
		   return 0;
		  }
		  var ls = 0;
		  if (s.match(/[a-z]/ig)){
		   ls++;
		  }
		  if (s.match(/[0-9]/ig)){
		   ls++;
		  }
		   if (s.match(/(.[^a-z0-9])/ig)){
		   ls++;
		  }
		  return ls;
	 }
	 function checkpwd(s)
	 {
		 if(s.length < 6){
			return false;
		 }
		 if(s.length > 20){
			return false;
		  }		  
		  var ls = 0;
		  if (s.match(/[a-z]/ig)){
		   ls++;
		  }
		  if (s.match(/[0-9]/ig)){
		   ls++;
		  }
		  if(ls==2){
			  return true;
		  }else{
			  return false;
		  }
	 }
		function savePS(){

			//如果用户修改密码
			if($('#newPassword1').val()!=$('#newPassword2').val()){
				alert('两次输入的新密码不一致，请输入相同的密码！');
				return false;
			}
			if($('#newPassword').val()!='ABC123abc'){
				if(!checkpwd($('#newPassword1').val())){
					alert('密码长度必须大于6位小于20位,至少包含字母和数字！');
					return false;
				}
			}
			var actionUrl = '<c:url value="/permissions/modifyPSUser.tg"/>';	
			$('#myform').form('submit', {
				url:actionUrl,
				success: function(data){
					$('#dlg').dialog('close');
					data=eval('('+data+')');
					if(data.success){
						$.messager.show(
							{
								title:'提示',
								msg:'操作成功！',
								showType:'slide'
							}
						);
					}
					if(data.error){
						$.messager.alert('提示','操作失败！','error');
					}
				}
			});
		}
		
		function modifyPS(){
			$('#myform').form('clear');
			document.getElementById("chkResult").innerHTML='';
			$('#dlg').dialog('setTitle', '修改密码').dialog('open');
			$("#dlg-buttons a::first-child").show();
		}	 
		
		function viewAllTask(){
			var param = {};
			$('#taskViews').dialog('setTitle', '任务查看').dialog('open');
			$('#t-userTaskNotify').datagrid('options').url = "<c:url value='/cust/getItemsUserTaskNotify.tg'/>";
			$('#t-userTaskNotify').datagrid("load", param);
			
		}
		
		function viewNoDoTask(){
			var param = {};
			$('#taskViews').dialog('setTitle', '消息查看').dialog('open');
			countNodo();
		}
        
		function count()
	    {		
			var actionUrl = '<c:url value='/cust/getAllCountUserTaskNotify.tg'/>';	
			$('#form1').form('submit', {
				url:actionUrl,
				success: function(data){
					
					data=eval('('+data+')');
    					/* if(data.totalCount!=null){
    						$('#count').text(data.totalCount);
    					} */
    					if(data.noDoCount!=null){
							$('#count1').text(data.noDoCount);
							if(data.noDoCount>0){
								$.messager.show({
									title : '提示',
									msg : "你有"+data.noDoCount+"条新新消息！",
									showType : 'slide'
								});
							}
						}
    					/* if(data.totalCount==null){
    						$('#count').text(0);
    					} */
    					if(data.noDoCount==null){
    						$('#count1').text(0);
    					}
					if(data.error){
						$.messager.alert('提示','操作失败！','error');
					}
				}
			});
	    } 
		function countNodo()
	    {
			var actionUrl = '<c:url value='/cust/getNoDoItemsUserTaskNotify.tg'/>';	
			$('#form2').form('submit', {
				url:actionUrl,
				success: function(data){
					data=eval('('+data+')');
					
					var commentTable = $('#showTable')[0];
					while(commentTable.rows.length>1){
						for(var j=1;j<commentTable.rows.length;j++){
							commentTable.deleteRow(j);
						}
                    }
					for(var i=0;i<data.rows.length;i++){
                    	var tmpObj = data.rows[i];
                    	var newTR = commentTable.insertRow(i+1);
                    	var newNameTD=newTR.insertCell(0);
                    	//添加列内容
                    	newNameTD.innerHTML = tmpObj.creatorName;
                    	var newCommentTD=newTR.insertCell(1);
                    	//添加列内容
                    	newCommentTD.innerHTML = tmpObj.notifyContent;
                    	var newdateTD=newTR.insertCell(2);
                    	//添加列内容
                    	newdateTD.innerHTML = tmpObj.notifyDate;
                    	var newdateTD=newTR.insertCell(3);
                    	//添加列内容
                    	newdateTD.innerHTML = tmpObj.taskNotifyId; 
                    	newdateTD.style.display="none";
                    	SetTableColor("showTable");
                    }
				}
			});
	    } 
		function countDo()
	    {		
			var actionUrl = '<c:url value='/cust/getDoItemsUserTaskNotify.tg'/>';	
			$('#form3').form('submit', {
				url:actionUrl,
				success: function(data){
					data=eval('('+data+')');
					var commentTable = $('#showTable')[0];
					while(commentTable.rows.length>1){
						for(var j=1;j<commentTable.rows.length;j++){
							commentTable.deleteRow(j);
						}
                    }
					if(data.rows.length>0){
						for(var i=0;i<data.rows.length;i++){
	                    	var tmpObj = data.rows[i];
	                    	var newTR = commentTable.insertRow(i+1);
	                    	var newNameTD=newTR.insertCell(0);
	                    	//添加列内容
	                    	newNameTD.innerHTML = tmpObj.creatorName;
	                    	var newCommentTD=newTR.insertCell(1);
	                    	//添加列内容
	                    	newCommentTD.innerHTML = tmpObj.notifyContent;
	                    	var newdateTD=newTR.insertCell(2);
	                    	//添加列内容
	                    	newdateTD.innerHTML = tmpObj.notifyDate;
	                     	var newdateTD=newTR.insertCell(3);
	                    	//添加列内容
	                    	newdateTD.innerHTML = tmpObj.taskNotifyId; 
	                    	newdateTD.style.display="none";
	                    	SetTableColor("showTable");
	                    }
					}
					
				}
			});
	    }
		function SetTableColor(TableID) {
			
		    var clickClass = "";        //点击样式名
		    var moveClass = "";         //鼠标经过样式名
		    var clickTR = null;         //点击的行
		    var moveTR = null;          //鼠标经过行
		    var Ptr = document.getElementById(TableID).getElementsByTagName("tr");
		  /*   for (i = 1; i < Ptr.length + 1; i++) {
		        Ptr[i - 1].className = (i % 2 > 0) ? "Rep_Tab_EvenTr" : "Rep_Tab_OddTr";
		    } */
		    //设置鼠标的动作事件
		    for (var i = 1; i < Ptr.length; i++) {
		        var Owner = Ptr[i].item;
		        //鼠标经过事件
		        Ptr[i].onmouseover = function Move() {
		            if (clickTR != this) {
		                if (moveTR != this) {
		                    moveClass = this.className;
		                    moveTR = this;
		                    this.className = "Rep_Tr_Move";
		                }
		            }
		        }
		        //鼠标离开事件
		        Ptr[i].onmouseout = function Out() {
		            if (clickTR != this) {
		                moveTR = null;
		                this.className = moveClass;
		            }
		        }
		        //鼠标单击事件
		        Ptr[i].onclick = function Ck() {
		        	
		            if (clickTR != this) {
		                if (clickTR) {
		                    clickTR.className = clickClass;
		                }
		                clickTR = this;
		                clickClass = moveClass;
		            }
		            this.className = "Rep_Tr_Click";
		            if(this.children.length==4){
   		        	 str="    "+ this.children.item(1).innerText;
   		        	 document.getElementById("showContents").value=str;
   		        	$('#cid').val(this.children.item(3).innerHTML);
   		        	var actionUrl = '<c:url value='/cust/updateNoDoItemstoDoUserTaskNotify.tg'/>';
		   		         $('#form3').form('submit', {
		   					url:actionUrl,
		   					success: function(){
		   						count();
		   					}
		   				});
   		         } 
		        }
		    }
		   
		}		
    </script>   
    <style type="text/css">
	    .task{
	        display: block;
			height: 21px;
			position: absolute;
			top: 27px;
			right: 0;
			z-index: 31;
			color: #33ff33;
	    }
		/*-----------------Repeater 控件内部Table样式定义-----------------*/
		/*　Repeater内部Table的样式 */
		.Rep_tab
		{
		    width: 100%;
		    margin: 0px auto;
		    padding-lett:10px;
		    font: Georgia 11px;
		    font-size: 12px;
		    font-family: Tahoma, Arial, Helvetica, Sans-serif, "宋体";
		    color: #333333;
			/* text-align: center; */
		    vertical-align:middle;
		    border-collapse: collapse; /*细线表格代码*/
		    
		}
		/*　Repeater内部Table的td样式 */
		.Rep_tab td
		{
		    border:1px solid #ECECEC; /*细线表格线条颜色*/
		    height: 35px;
		    width:10px;
		}
		/*　Repeater内部Table的caption样式 */
		.Rep_tab caption
		{
		    text-align: center;
		    font-size: 12px;
		    font-weight: bold;
		    margin: 0 auto;
		}
		/*　Repeater内部Table的TR的奇数行样式 */
		.Rep_Tab_OddTr
		{
		    background-color: #f8fbfc;
		    color: #000000;
		    height: 25px;
		     
		}
		/*　Repeater内部Table的TR的偶数行样式 */
		.Rep_Tab_EvenTr
		{
		    background-color: #e5f1f4;
		    color: #000000;
		    height: 25px;
		}
		.Rep_Tab_HeaderTr
		{
		    background-color: #ffffee;
		    color: #000000;
		}
		/*鼠标经过的颜色*/
		.Rep_Tr_Move
		{
		    background-color: #ecfbd4;
		    color: #000000;
		    height: 25px;
		}
		/* 鼠标点击的颜色*/
		.Rep_Tr_Click
		{
		    background-color: #ECECEC;
		    color: #333333;
		    height: 25px;
		}
    </style>
    <link rel="stylesheet" href="<c:url value="/tg/commons/easyui/themes/default/easyui.css"/>" type="text/css" />
    <link rel="stylesheet" href="<c:url value="/tg/commons/easyui/themes/icon.css"/>" type="text/css" />
    <script src="<c:url value="/tg/commons/easyui/jquery-1.6.min.js"/>"></script>
    <script src="<c:url value="/tg/commons/easyui/jquery.easyui.min.js"/>"></script>
    <script src="<c:url value="/tg/commons/easyui/locale/easyui-lang-zh_CN.js"/>"></script>
    <script type="text/javascript" src='<c:url value="/js/outlook3.js"/>'> </script>
</head>
<body class="easyui-layout" style="overflow-y: hidden"  scroll="no" onload="setInterval('count()', 1800000);count();">
<noscript>
<div style=" position:absolute; z-index:100000; height:2046px;top:0px;left:0px; width:100%; background:white; text-align:center;">
    <img src="images/noscript.gif" alt='抱歉，请开启脚本支持！' />
</div></noscript>

		<div region="north" id="header" style="height:88px;">
			<div class="headerNav">
				<a class="logo" href="#">标志</a>
				<ul class="nav">
					
					<li><a href="#" onclick="return false;" width="600">欢迎 <%=request.getAttribute("loginStr")%>  </a></li>
					<li><a href="#" onclick="modifyPS();return false;" target="dialog" width="600">修改密码</a></li>
					<!-- 
					<li><a href="http://www.cnblogs.com/dwzjs" target="_blank">博客</a></li>
					<li><a href="http://weibo.com/dwzui" target="_blank">微博</a></li>
					<li><a href="http://bbs.dwzjs.com" target="_blank">论坛</a></li>
					 -->
					<li><a href="logoutLogin.tg" id="loginOut">退出</a></li>
				</ul>
				<ul class="task" style="margin-left: 100px;right: 131px">
					<li>未读消息(<a href="#" style="color:red" onclick="viewNoDoTask()" width="600"><span id="count1"></span></a>) </li>
				</ul>
				
			</div>
		
			<div id="navMenu">
				<ul>
					<%=request.getAttribute("strFirstMenu")%>

				</ul>
			</div>
		</div>
		
    <div region="south" split="true" style="height: 30px; background: #D2E0F2; ">
        <div class="footer">综合客户关系管理系统</div>
    </div>
    <div region="west" hide="true" split="true" title="导航菜单" style="width: 180px;" id="west">
        <div id='wnav' class="easyui-accordion" fit="true" border="false">
            <!--  导航内容 -->
        </div>
    </div>
    <div id="mainPanle" region="center" style="background: #eee; overflow-y: hidden">
        <div id="tabs" class="easyui-tabs" fit="true" border="false">
            <div title="欢迎使用" style="padding: 20px; overflow: hidden;" id="home">
                
            </div>
        </div>
    </div>
	<div id="mm" class="easyui-menu" style="width:150px;">
		<div id="mm-tabupdate">刷新</div>
		<div class="menu-sep"></div>
		<div id="mm-tabclose">关闭</div>
		<div id="mm-tabcloseall">全部关闭</div>
		<div id="mm-tabcloseother">除此之外全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-tabcloseright">当前页右侧全部关闭</div>
		<div id="mm-tabcloseleft">当前页左侧全部关闭</div>
		<div class="menu-sep"></div>
		<div id="mm-exit">退出</div>
	</div>
	<div id="dlg" style="width:350px;height:200px;"
			class="easyui-dialog" closed="true" modal="true" buttons="#dlg-buttons">
		<div style="padding-left:50px;padding-top:20px;">
			<div style="float:center">
				<form id="myform" method="post" style="margin:0;padding:0">
					<table>
						<tr>
							<td width="80px">旧密码</td>
							<td><input type="password" id="oldPassword"
								class="easyui-validatebox e-input" name="user.password"
								required="true">
								<br/>
							</td>
						</tr>						
						<tr>
							<td>新密码</td>
							<td><input type="password" id="newPassword1"
								class="easyui-validatebox e-input" name="user.ext1"
								required="true" onblur="chkpwd(this)">
								<br/>
								<div id="chkResult"></div></td>
						</tr>						
						<tr>
							<td>确认密码</td>
							<td><input type="password" id="newPassword2"
								class="easyui-validatebox e-input" name="user.ext2"
								required="true">
								<br/>
							</td>
						</tr>					
					</table>
				</form>		
			</div>
			<div style="clear:both"></div>
		</div>
		<div id="dlg-buttons" style="text-align:center;">
			<a href="#" class="easyui-linkbutton" iconCls="icon-save" onclick="savePS()">保存</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
		</div>
	</div>	
	
	<div  id="taskViews" style="width:800px;height:500px;"
			class="easyui-dialog" closed="true" modal="true" >
		<div class="easyui-layout" fit="true">  
        <div region="north" border="false">  
        </div>
        <form id="form3"> 
        <input type="hidden" id="cid" name="id" value=""/>
         </form> 
        <div region="center" border="false">  
            <div class="easyui-layout" fit="true">  
                <div region="west" border="false" style="width:100px;height:400px;">  
             		<div class="easyui-accordion" fit="true" border="false">
	             		<ul style="margin-top: 10px">
	            			<li><h4><a href="return false;" width="600" onclick="countNodo();return false;" ><span>未读消息</span></a></h4></li>
	            			<li><h4><a href="return false;" width="600" onclick="countDo();return false;" ><span>已读消息</span></a></h4></li>
	            		</ul>	
        			</div>
                </div>  
                <div region="center" border="false" style="border:1px solid #ccc;">  
                    <div class="easyui-layout" fit="true">  
                        <div region="north" split="true" border="false" style="height:300px;"> 
                        	
	                           <table id="showTable" class="Rep_tab" width="680" border="0" cellpadding="0" cellspacing="0" align="center">
		                           <thead>
		                           		<tr>
		                           			
		                           			<td >发送人</td>
		                           			<td >消息内容</td>
		                           			<td >发送时间</td>
		                           			<td hidden="true"></td>
		                           		</tr>
		                           	</thead>	
	                           </table>
                           
                        </div>  
                        <div region="center" border="false">  
                        	<textarea  id='showContents' name="content" id="content" style="width: 660px; height: 120px; margin: 6px; " /></textarea>
                        </div>  
                    </div>  
                </div>  
            </div>  
        </div>  
    </div>  
	</div>
	 <form id="form1">
    </form>
     <form id="form2">
    </form>
    
</body>
</html>